package com.mf.controller.basic;


import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.mf.aspect.debounces.Debounce;
import com.mf.aspect.logApi.LogApi;
import com.mf.groups.GroupsAddInterface;
import com.mf.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


import com.mf.entity.req.basic.ReqUserRole;
import com.mf.service.basic.ServiceUserRole;

/**
 * 权限角色关联关系
 */
@RestController
@RequestMapping("userRole")
@SaCheckLogin
@Tag(name = "权限角色关联关系")
@Debounce
public class ControllerUserRole {
    @Resource
    private ServiceUserRole serviceuserRole;


    @Operation(summary = "根据用户ids关联角色")
    @SaCheckPermission("role:upUser")
    @LogApi("根据用户ids关联角色")
    @PostMapping("/addByAppend")
    public Result<Void> addByAppend(@Validated(GroupsAddInterface.class) @RequestBody ReqUserRole reqUserRole) {
        serviceuserRole.addByAppend(reqUserRole);
        return Result.success();
    }


    @LogApi("根据角色id删除关联用户")
    @Operation(summary = "根据角色id删除关联用户")
    @SaCheckPermission("role:upUser")
    @PostMapping("/delete")
    public Result<Void> delete(@Validated(GroupsAddInterface.class) @RequestBody ReqUserRole reqUserRole) {
        serviceuserRole.deleteByRoleId(reqUserRole);
        return Result.success();
    }


}
